//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.emin.platform.productCenter.service.impl;

import com.emin.base.dao.PreFilter;
import com.emin.base.dao.PreFilters;
import com.emin.base.dao.SortKey;
import com.emin.base.exception.EminException;
import com.emin.base.service.UndeleteableServiceImpl;
import com.emin.platform.productCenter.entity.Person;
import com.emin.platform.productCenter.service.PersonService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("personService")
@Transactional
public class PersonServiceImpl extends UndeleteableServiceImpl<Person> implements PersonService {
    public PersonServiceImpl() {
    }

    @Transactional
    public Person login(String mobilePhone, String password) {
        if (null != mobilePhone && null != password) {
            PreFilter mobileFilter = PreFilters.eq("mobilephone", mobilePhone);
            PreFilter passwordFilter = PreFilters.eq("password", password);
            PreFilter statusFilter = PreFilters.ge("status", Integer.valueOf(0));
            List<Person> person = this.findAll((SortKey[]) null);
            if (null == person) {
                throw new EminException("2.3.2", new Object[0]);
            } else {
                return (Person) person.get(0);
            }
        } else {
            throw new RuntimeException("账号或密码不能为空");
        }
    }
}
